package com.wn.ziroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wn.ziroom.entity.Areas;
import com.wn.ziroom.entity.Cities;
import com.wn.ziroom.mapper.AreasMapper;
import com.wn.ziroom.service.AreasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Service
public class AreasServiceImpl extends ServiceImpl<AreasMapper, Areas> implements AreasService {

    @Autowired
    private AreasMapper areasMapper;


    @Cacheable(value = "area",key = "#root.methodName")
    @Override
    public List<Areas> getShangHaiArea() {
        LambdaQueryWrapper<Areas> areasLambdaQueryWrapper = new LambdaQueryWrapper<>();
        areasLambdaQueryWrapper.eq(Areas::getProvinceCode, 31);
        return areasMapper.selectList(areasLambdaQueryWrapper);
    }

    @Override
    public List<Areas> findListByCityCode(String cityCode) {
        QueryWrapper<Areas> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("cityCode",cityCode);

        return areasMapper.selectList(queryWrapper);
    }
}
